//package com.fecean.aabbc.netty.client.prod3;
//
//import com.fecean.aabbc.netty.message3.MessageRegister;
//import io.netty.channel.ChannelHandler;
//import io.netty.channel.ChannelHandlerContext;
//import io.netty.channel.SimpleChannelInboundHandler;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;
//import java.time.Instant;
//import java.util.UUID;
//
///**
// * NettyServerHeartBeatHandler
// *
// * @author: chenfenghai
// * @version: 1.0
// * @date: 2020-03-05 15:59
// * @blame Team
// */
//@Slf4j
//@Component
//@ChannelHandler.Sharable
//public class NettyClientRegisterHandler extends SimpleChannelInboundHandler<MessageRegister> {
//
//    @Resource
//    NettyClientChannel nettyClientChannel;
//
//    /**
//     ** 影院配置
//     */
//    @Resource
//    CinemaConfig cinemaConfig;
//
//    @Override
//    public void channelActive(ChannelHandlerContext ctx) {
//        log.info("客户端[{}-{}]连接成功", cinemaConfig.getTenantId(), cinemaConfig.getCinemaCode());
//        MessageRegister messageRegister = new MessageRegister();
//        messageRegister.setId(UUID.randomUUID().toString());
//        messageRegister.setTimestamp(Instant.now().toEpochMilli());
//        messageRegister.setTenantId(cinemaConfig.getTenantId());
//        messageRegister.setCinemaCode(cinemaConfig.getCinemaCode());
//        ctx.writeAndFlush(messageRegister);
//        ctx.fireChannelActive();
//    }
//
//    @Override
//    protected void channelRead0(ChannelHandlerContext ctx, MessageRegister messageRegister) throws Exception {
//        nettyClientChannel.setChannel(ctx.channel());
//        log.info("客户端[{}-{}]注册成功",
//                messageRegister.getTenantId(),
//                messageRegister.getCinemaCode());
//    }
//
//    @Override
//    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
//        nettyClientChannel.clear();
//        ctx.fireChannelInactive();
//    }
//}
